package cn.onein.edu.manage.domain;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

@Entity
@Table(name="learn_category")
public class LearnCategory {

	@Id
	@Column(name="ID")
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	private Long id;
	
	@ManyToOne
	@JoinColumn(name = "PARENT_ID")
	private LearnCategory parent;
	
	@OneToMany(mappedBy = "parent",fetch=FetchType.EAGER)
	private Set<LearnCategory> children = new HashSet<LearnCategory>();
	
	@OneToMany(mappedBy = "category",fetch=FetchType.EAGER)
	private Set<LearnContent> contents = new HashSet<LearnContent>();
	
	@ManyToOne(optional = false,fetch=FetchType.LAZY)
	@JoinColumn(name = "SECTION_ID", nullable = false)
	private LearnSection section;
	
	@Column(name="NAME")
	private String name;
	
	@Column(name="TITLE")
	private String title;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public LearnCategory getParent() {
		return parent;
	}

	public void setParent(LearnCategory parent) {
		this.parent = parent;
	}

	public Set<LearnCategory> getChildren() {
		return children;
	}

	public void setChildren(Set<LearnCategory> children) {
		this.children = children;
	}

	public LearnSection getSection() {
		return section;
	}

	public void setSection(LearnSection section) {
		this.section = section;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public Set<LearnContent> getContents() {
		return contents;
	}

	public void setContents(Set<LearnContent> contents) {
		this.contents = contents;
	}
	
	
}
